package cn.ytian.scashier;

import java.util.List;

import static cn.ytian.scashier.Language.*;
import static cn.ytian.scashier.YLib.*;

public class DocUi {
    public static void cls() {
        for (int i = 0; i < 80; i++) {
            YLib.pln("\n");
        }
    }

    public static void LoadMenu() {
        LoadMenu(Menu_List, Menu_Title, Menu_Exit);
    }

    static void LoadMenu(List<String> menu_list, String Title, String Exit) {
        pln("\t========%s========", Title);
        for (int i = 0; i < menu_list.size(); i++) {
            String str = menu_list.get(i);
            pln("\t\t%d.%s", i + 1, str);
        }
        pln("\t\t0.%s", Exit);
    }

    static void LoadList(List<String> menu_list, String Title, String type) {
        pln("\t========%s========", Title);
        PLH(type);
        for (int i = 0; i < menu_list.size(); i++) {
            String str = menu_list.get(i);
            pln(str);
        }
    }

    public static void PLH() {
        String str = "\t" + LH_Id +
                "\t\t" + LH_Name +
                "\t\t" + LH_Price;
        pln(str);
    }

    public static void PLH(String type) {
        String str = "\t" + LH_Id +
                "\t\t" + LH_Name +
                "\t\t" + LH_Price;
        if (type.equals("S")) {
            str = "\t" + LH_serial + "\t" + str + "\t\t" + LH_Quantity + "\t\t" + LH_Subtotal;
        }
        if (type.equals("O")){
            str=Sales_PLH;
        }
        pln(str);
    }

    public static boolean InputJB(String str, String key) {
        pl(str);
        String in = Yin();
        return in.equals(key);
    }

    public static boolean InputJBD(String str, String key) {
        pl(str);
        String in = Yin();
        return in.equals(key.toLowerCase()) || in.equals(key.toUpperCase());
    }

    public static boolean InputJB(String str, String key, Object... args) {
        pl(str, args);
        String in = Yin();
        return in.equals(key);
    }

    public static String InputStr(String str) {
        pl(str);
        return Yin();
    }

    public static String InputStr(String str, Object... args) {
        pl(str, args);
        return Yin();
    }

    public static String InputStrLn(String str) {
        pln(str);
        return Yin();
    }

    public static String InputLine(String str) {
        pln(str);
        return YinLine();
    }

    public static String InputLine(String str, Object... args) {
        pln(str, args);
        return YinLine();
    }


    public static int InputInt(String str) {
        pl(str);
        return YinInt();
    }

    public static int InputInt(String str, Object... args) {
        pl(str, args);
        return YinInt();
    }

}
